<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<script src="js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" href="css/login.css"/>
		<title></title>
	</head>
	<body>
		
	<div class="header">
		淘宝账户登录
	</div>
	<div class="logo">
		<img src="img/淘宝/登录_files/logo.png"/>
	</div>
	<ul>
		<li>
			<span>账户</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="text" placeholder="手机号/邮箱/会员号" class="telephone"/>
		</li>
		<li>
			<span>登录密码</span>&nbsp;<input type="password" placeholder="请输入密码" class="password"/>
		</li>
	</ul>
	
	<div class="login">
		登录
	</div>
	<div class="footer">
		<a href="sign.html">免费注册</a>
		<a href="">忘记密码</a>
	</div>
	<div class="notLogin" id="notLogin">
			<div class="reminder" id="reminder">
				<p>您输入的密码不正确</p>
				<button id="btn">
					确定
				</button>
			</div>
	</div>

		<script>
		


    (function () {
        size();
        window.onresize = function () {
            size();
        }
        function size() {
            var winW = document.documentElement.clientWidth || document.body.clientWidth;
            document.documentElement.style.fontSize =  (winW / 375)*100 + "px";
        }
    })()


		var username=sessionStorage.getItem('username');
		$('.telephone').val(username);
		$('.login').click(function(){
			var telephone=$('.telephone').val();
			var password=$('.password').val();
			if (telephone!='' && password!='') {
				$.ajax({
			type:"post"
			,url:"http://47.92.37.168/supermarket/data/login.php"
			,async:true
			,data:{
				user_phone:telephone,
				user_pass_word:password
			}
			,dataType:"jsonp"
			,jsonp:"callback"
			,jsonpCallback:"success_JsonpCallback"
//			,jsonp: "callbackparam",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
//           jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
			,success:function(data){
				console.log(data);
				
				if (data.msg=='success') {
					alert('success');
					//保存数据
					sessionStorage.setItem('username',telephone);
					sessionStorage.setItem('useraddr',data.info.user_addr);
					location.href="index.html";
				} else if(data.msg=='error'){
					alert('error');					
					$('.notLogin').css('display','block');
					$('.reminder p').text(data.reason);
				}
			}
			,error:function(){
				alert('error!');
			}
		});
	}
})
$('#btn').click(function(){
	$('.notLogin').css('display','none');
})

</script>
</body>
</html>